import umn.monopolybankservice.Player
import umn.monopolybankservice.Game

class BootStrap {

    def defaultGame

    def init = { servletContext ->
        if(!Game.count()) {
            defaultGame = new Game(name: "defaultGame")
            defaultGame.save(failOnError: true)
        }
        else {
            defaultGame = Game.findByName( "defaultGame" )
        }
        if(!Player.count()) {
            new Player(name: "Curly", wallet: 10.5, game: defaultGame).save(failOnError: true)
            new Player(name: "Larry", wallet: 4, game: defaultGame).save(failOnError: true)
            new Player(name: "Moe", wallet: 6, game: defaultGame).save(failOnError: true)
        }
    }
    def destroy = {
    }
}
